var mapLocation_callback = myApp.onPageInit('location', function (page) {
    var lat = page.query.lat;
    var lng = page.query.lng;
    var index = page.query.index; 

    //定义地图
    var mMap = new BMap.Map("mapcontainer", { enableMapClick: false });
    //启用滚轮放大缩
    mMap.enableScrollWheelZoom();
    //添加缩放控件
    var navigationControl = new BMap.NavigationControl({
        //靠左上角位置
        anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
        //LARGE类型
        type: BMAP_NAVIGATION_CONTROL_ZOOM
    });
    mMap.addControl(navigationControl);
    // 添加定位控件
    var geolocationControl = new BMap.GeolocationControl();
    mMap.addControl(geolocationControl);
    //绑定地理位置
    var point = new BMap.Point(lng, lat);
    mMap.centerAndZoom(point, 15);
    mMap.panTo(point);

    //中心点反编码获取附近点
    var GetNearByPois = function (centerPoint) {
        var geocoder = new BMap.Geocoder();
        geocoder.getLocation(centerPoint, function (data) {
            if (data && data.surroundingPois!=null && data.surroundingPois.length > 0) {
                $$("#location_page .navbar .center").html(data.surroundingPois[0].title);
                var localResultPoi = data.surroundingPois;
                var searchTemplate = $$('#nearby-poi-template').html();
                if (searchTemplate) {
                    var compiledTemplate = Template7.compile(searchTemplate);
                    var html = compiledTemplate(localResultPoi);
                    $$("#location_page #address-list ul").html(html);

                    $$("#location_page #address-list ul li").each(function(){
                        $$(this).on("click",function(){
                            var title=$$(this).attr("title");
                            var lat=$$(this).attr("lat");
                            var lng=$$(this).attr("lng");
                            var obj={index:index,title:title,lat:lat,lng:lng};
                            iss_localStorage.set("yuqing_poi",JSON.stringify(obj));
                            mainView.router.back();
                        })
                    })
                }
            }
        }, { poiRadius: 1000, numPois: 10 });
    }

    GetNearByPois(point);

    mMap.addEventListener("dragging", function () {
        var poi = mMap.getCenter();
        GetNearByPois(poi);
    })
});